-
Notifications
You must be signed in to change notification settings - Fork 402
Use the dummy codegen backend #4648
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| /// Also disable the MIR pass that inserts an alignment check on every pointer dereference. Miri | ||
| /// does that too, and with a better error message. | ||
| pub const MIRI_DEFAULT_ARGS: &[&str] = &[ | ||
| "-Zcodegen-backend=dummy", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The dummy codegen backend is a builtin codegen backend that is only capable of emitting rlibs containing the crate metadata. For every other crate type it emits an error after codegen. This is fine for miri as for --crate-type bin, miri exits before codegen.
…apkin Allow codegen backends to indicate which crate types they support This way cargo will drop the unsupported crate types for crates that specify multiple crate types. This is a prerequisite for rust-lang/miri#4648.
…, r=WaffleLapkin Allow codegen backends to indicate which crate types they support This way cargo will drop the unsupported crate types for crates that specify multiple crate types. This is a prerequisite for rust-lang/miri#4648.
Rollup merge of #148177 - bjorn3:codegen_backend_crate_types, r=WaffleLapkin Allow codegen backends to indicate which crate types they support This way cargo will drop the unsupported crate types for crates that specify multiple crate types. This is a prerequisite for rust-lang/miri#4648.
ac1e234 to
ef6aed4
Compare
This comment has been minimized.
This comment has been minimized.
…es, r=JonathanBrouwer Handle default features and -Ctarget-features in the dummy backend This prevents a warning about ABI relevant target features not being set on x86 and arm. In addition it is required for miri to report correct features in is_*_feature_detected!() if miri switches to the dummy backend. Required for rust-lang/miri#4648
…es, r=JonathanBrouwer Handle default features and -Ctarget-features in the dummy backend This prevents a warning about ABI relevant target features not being set on x86 and arm. In addition it is required for miri to report correct features in is_*_feature_detected!() if miri switches to the dummy backend. Required for rust-lang/miri#4648
…es, r=JonathanBrouwer Handle default features and -Ctarget-features in the dummy backend This prevents a warning about ABI relevant target features not being set on x86 and arm. In addition it is required for miri to report correct features in is_*_feature_detected!() if miri switches to the dummy backend. Required for rust-lang/miri#4648
Rollup merge of #148253 - bjorn3:dummy_backend_target_features, r=JonathanBrouwer Handle default features and -Ctarget-features in the dummy backend This prevents a warning about ABI relevant target features not being set on x86 and arm. In addition it is required for miri to report correct features in is_*_feature_detected!() if miri switches to the dummy backend. Required for rust-lang/miri#4648
a4a79ee to
ff9ef3b
Compare
|
Almost there. With rust-lang/rust#148177 and rust-lang/rust#148253 merged, the entire miri test suite passes after blessing a single change to a query cycle error. Doctests are broken however due to those requiring a check build for bin crates first, which the dummy codegen backend doesn't yet allow. Opened rust-lang/rust#148299 for this. |
5f8c2f8 to
38dd4f6
Compare
|
I hadn't noticed the cargo-miri-test test suite before. It currently has trouble with non-rlib/bin crate types. In particular cargo thinks it needs to build crates only available as cdylib (despite those never being usable) and the |
Allow check builds with binaries for the dummy codegen backend This is likely the last part necessary for rust-lang/miri#4648. Miri needs to be able to do a regular check build for compile_fail doc tests to work.
95b1a48 to
cad7423
Compare
|
Thank you for contributing to Miri! |
…athanBrouwer Handle default features and -Ctarget-features in the dummy backend This prevents a warning about ABI relevant target features not being set on x86 and arm. In addition it is required for miri to report correct features in is_*_feature_detected!() if miri switches to the dummy backend. Required for rust-lang/miri#4648
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/bin/miri.rs
Outdated
| if config.opts.prints.is_empty() && self.target_crate { | ||
| // Avoid warnings about unsupported crate types | ||
| #[allow(rustc::bad_opt_access)] | ||
| config.opts.crate_types.retain(|&c| c == CrateType::Executable || c == CrateType::Rlib); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably only do this for target crates?
What happens if the list of crate types is empty after the filtering?
Also, why is it okay to allow bad_opt_access here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably only do this for target crates?
This is gated behind if self.target_crate.
What happens if the list of crate types is empty after the filtering?
Currently rustc treats that as implicit --crate-type lib, but in any case it shouldn't be possible to get an empty list here. Cargo will error if none of the crate types are bin or rlib as the dummy codegen backend only lists those crate types as supported.
Also, why is it okay to allow bad_opt_access here?
This is long before the TyCtxt gets created that you are normally supposed to access crate_types through.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently rustc treats that as implicit --crate-type lib, but in any case it shouldn't be possible to get an empty list here. Cargo will error if none of the crate types are bin or rlib as the dummy codegen backend only lists those crate types as supported.
Please add an assertion then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently rustc treats that as implicit --crate-type lib
Actually, it treats it as --crate-type bin just like if the user didn't pass --crate-type at all. I got it confused with the behavior when --crate-type is present on the cli, but all listed crate types are unsupported by the target or codegen backend.
In any case I added an assertion.
ba4b99f to
dae6966
Compare
|
@rustbot ready |
|
This looks great, thanks! Please squash the commits using @rustbot author |
This allows getting rid of all the argument mangling hacks as well as the exported_non_generic_symbols override hack by doing cargo build instead of cargo check. This is also a prerequisite for using native jit mode support in miri that I hope to add to rustc in the future to be used with cg_clif too.
|
@rustbot ready |
|
All right, let's see how well this works :) |
This allows getting rid of all the argument mangling hacks as well as the exported_non_generic_symbols override hack by doing cargo build instead of cargo check. This is also a prerequisite for using native jit mode support in miri that I hope to add to rustc in the future to be used with cg_clif too.